package com.njwb.day15.zqzb.method.anno3;

import java.lang.reflect.Method;

public class Student {

    private String name;
    private int age ;
    private String birthday;

    @InitAnnotation(name="张三",age=15,birthday="2022-1-1")
    public void initParams()  {
        Class cls = this.getClass() ;
        try {
            Method m =cls.getDeclaredMethod("initParams");
            InitAnnotation myAnnotation3 = m.getAnnotation(InitAnnotation.class);
            this.name = myAnnotation3.name();
            this.age = myAnnotation3.age();
            this.birthday = myAnnotation3.birthday();
            System.out.println("注解处理完毕");
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        }
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", birthday='" + birthday + '\'' +
                '}';
    }
}
